001 /* 002 * Copyright (c) 2005 Stephen J. McConnell 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.metro.tools; 020 021 import net.dpml.metro.info.ServiceDescriptor; 022 023 import net.dpml.lang.Version; 024 025 import org.apache.tools.ant.BuildException; 026 027 /** 028 * Declaration of an exported service. 029 * 030 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a> 031 * @version 1.1.0 032 */ 033 public class ServiceDataType 034 { 035 private String m_classname; 036 private Version m_version; 037 038 /** 039 * Set the service classname. 040 * @param classname the name of the service interface class 041 */ 042 public void setClass( final String classname ) 043 { 044 if( null == classname ) 045 { 046 throw new NullPointerException( "classname" ); 047 } 048 m_classname = classname; 049 } 050 051 /** 052 * Set the service version. 053 * @param spec the version value 054 */ 055 public void setVersion( final String spec ) 056 { 057 if( null == spec ) 058 { 059 throw new NullPointerException( "spec" ); 060 } 061 m_version = Version.parse( spec ); 062 } 063 064 ServiceDescriptor getServiceDescriptor() 065 { 066 if( null == m_classname ) 067 { 068 throw new BuildException( "Missing interface 'class' attribute." ); 069 } 070 else 071 { 072 return new ServiceDescriptor( m_classname, m_version ); 073 } 074 } 075 }